package com.security.manage.search.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.time.LocalDateTime;

@Document(indexName = "logs",type = "info",replicas = 0)
public class LogInfo implements Serializable {
    @Id
    private String id;
    @Field(type = FieldType.Keyword)
    private String classification;
    @Field(type = FieldType.Integer)
    private Integer recordNo;
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime recordTime;
    @Field(type = FieldType.Keyword)
    private String logType;
    @Field(type = FieldType.Integer)
    private Integer eventId;
    @Field(type = FieldType.Keyword)
    private String eventSource;
    @Field(type = FieldType.Keyword)
    private String userName;
    @Field(type = FieldType.Keyword)
    private String computerName;
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String logMessage="";
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String logData="";
    @Field(type = FieldType.Long)
    private Long userId=0L;
    @Field(type = FieldType.Long)
    private Long taskId=0L;
    @Field(type = FieldType.Long)
    private Long deptId=0L;

    public LogInfo(){

    }

    public LogInfo(String id,String classification, Integer recordNo, LocalDateTime recordTime, String logType, Integer eventId, String eventSource, String userName, String computerName) {
        this.id = id;
        this.classification = classification;
        this.recordNo = recordNo;
        this.recordTime = recordTime;
        this.logType = logType;
        this.eventId = eventId;
        this.eventSource = eventSource;
        this.userName = userName;
        this.computerName = computerName;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getClassification() {
        return classification;
    }

    public void setClassification(String classification) {
        this.classification = classification;
    }

    public Integer getRecordNo() {
        return recordNo;
    }

    public void setRecordNo(Integer recordNo) {
        this.recordNo = recordNo;
    }

    public LocalDateTime getRecordTime() {
        return recordTime;
    }

    public void setRecordTime(LocalDateTime recordTime) {
        this.recordTime = recordTime;
    }

    public String getLogType() {
        return logType;
    }

    public void setLogType(String logType) {
        this.logType = logType;
    }

    public Integer getEventId() {
        return eventId;
    }

    public void setEventId(Integer eventId) {
        this.eventId = eventId;
    }

    public String getEventSource() {
        return eventSource;
    }

    public void setEventSource(String eventSource) {
        this.eventSource = eventSource;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getComputerName() {
        return computerName;
    }

    public void setComputerName(String computerName) {
        this.computerName = computerName;
    }

    public String getLogMessage() {
        return logMessage;
    }

    public void setLogMessage(String logMessage) {
        this.logMessage = logMessage;
    }

    public String getLogData() {
        return logData;
    }

    public void setLogData(String logData) {
        this.logData = logData;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getTaskId() {
        return taskId;
    }

    public void setTaskId(Long taskId) {
        this.taskId = taskId;
    }

    public Long getDeptId() {
        return deptId;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    @Override
    public String toString() {
        return "LogInfo{" +
                "classification='" + classification + '\'' +
                ", recordNo=" + recordNo +
                ", recordTime=" + recordTime +
                ", logType='" + logType + '\'' +
                ", eventId=" + eventId +
                ", eventSource='" + eventSource + '\'' +
                ", userName='" + userName + '\'' +
                ", computerName='" + computerName + '\'' +
                ", logMessage='" + logMessage + '\'' +
                ", logData='" + logData + '\'' +
                '}';
    }
}
